{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:06:09.541293300Z",
     "start_time": "2023-06-14T02:06:09.528327Z"
    }
   },
   "outputs": [],
   "source": [
    "import func\n",
    "import warnings\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "\n",
    "FILE_PATH = \"../dataset/satisfaction_v2.csv\"\n",
    "PICTURE_PATH = \"../picture/\"\n",
    "K_FOLD=10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [],
   "source": [
    "data = func.get_pre_processed_data_set(FILE_PATH)\n",
    "train_data_list, test_data_list=func.split_data(data,k_fold=K_FOLD)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:06:10.229451300Z",
     "start_time": "2023-06-14T02:06:09.535309400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [],
   "source": [
    "acc_k_neighbors_list=[]\n",
    "acc_logistic_list=[]\n",
    "acc_random_forest_list=[]\n",
    "acc_xgboost_list=[]\n",
    "acc_decision_tree_list=[]\n",
    "for i in range(K_FOLD):\n",
    "    train_data=train_data_list[i]\n",
    "    test_data=test_data_list[i]\n",
    "    train_x, train_y = func.x_y_split(train_data, \"satisfaction_v2\")\n",
    "    test_x, test_y = func.x_y_split(test_data, \"satisfaction_v2\")\n",
    "    _,acc_k_neighbors=func.k_neighbors(train_x, train_y,test_x, test_y,n_neighbors=9)\n",
    "    acc_k_neighbors_list.append(acc_k_neighbors)\n",
    "    _,acc_logistic=func.logistic(train_x, train_y,test_x, test_y)\n",
    "    acc_logistic_list.append(acc_logistic)\n",
    "    _,acc_random_forest=func.random_forest(train_x, train_y,test_x, test_y,n_estimators=425)\n",
    "    acc_random_forest_list.append(acc_random_forest)\n",
    "    _,acc_xgboost=func.xgboost(train_x, train_y,test_x, test_y)\n",
    "    acc_xgboost_list.append(acc_xgboost)\n",
    "    _,acc_decision_tree=func.decision_tree(train_x, train_y,test_x, test_y)\n",
    "    acc_decision_tree_list.append(acc_decision_tree)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.422751300Z",
     "start_time": "2023-06-14T02:06:10.229451300Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7066038922974194\n"
     ]
    },
    {
     "data": {
      "text/plain": "[0.7234321902996602,\n 0.692254228125724,\n 0.6857672407135686,\n 0.6886005560704356,\n 0.6909413854351687,\n 0.7090895049810796,\n 0.7259808464627742,\n 0.7135686153370917,\n 0.7140319715808171,\n 0.722372383967874]"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(sum(acc_k_neighbors_list)/K_FOLD)\n",
    "acc_k_neighbors_list"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.437711200Z",
     "start_time": "2023-06-14T02:15:06.425837100Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7652041517024812\n"
     ]
    },
    {
     "data": {
      "text/plain": "[0.7646740809391411,\n 0.701289674878369,\n 0.7424511545293073,\n 0.7195705900525178,\n 0.7857749633176307,\n 0.8028419182948491,\n 0.8013592832869941,\n 0.7974360954513862,\n 0.7828403737740366,\n 0.7538033825005792]"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(sum(acc_logistic_list)/K_FOLD)\n",
    "acc_logistic_list"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.484611900Z",
     "start_time": "2023-06-14T02:15:06.437711200Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9582583665778674\n"
     ]
    },
    {
     "data": {
      "text/plain": "[0.9667902378745752,\n 0.9474090663371689,\n 0.9440111205498494,\n 0.9467099165894347,\n 0.9589929724303035,\n 0.9614642057301722,\n 0.9623880135928329,\n 0.9654799598424588,\n 0.9665611244111515,\n 0.9627770484207274]"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(sum(acc_random_forest_list)/K_FOLD)\n",
    "acc_random_forest_list"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.492590500Z",
     "start_time": "2023-06-14T02:15:06.453669700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9576328278952196\n"
     ]
    },
    {
     "data": {
      "text/plain": "[0.9657862218103181,\n 0.9484902309058615,\n 0.9409993049656344,\n 0.9470960766141489,\n 0.9581434859834737,\n 0.960846397405205,\n 0.9620018535681186,\n 0.9656344119237007,\n 0.9651710556799753,\n 0.9621592400957603]"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(sum(acc_xgboost_list)/K_FOLD)\n",
    "acc_xgboost_list"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.492590500Z",
     "start_time": "2023-06-14T02:15:06.469626800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9389668626566717\n"
     ]
    },
    {
     "data": {
      "text/plain": "[0.9481000926784059,\n 0.926249131207043,\n 0.9220016989728936,\n 0.9248532591906086,\n 0.9401498185188045,\n 0.943624990346745,\n 0.9460920605498919,\n 0.947331840296548,\n 0.9462506757278555,\n 0.945015059077921]"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(sum(acc_decision_tree_list)/K_FOLD)\n",
    "acc_decision_tree_list"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-06-14T02:15:06.500569600Z",
     "start_time": "2023-06-14T02:15:06.484611900Z"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
